package com.bum.api.processor.dj.html;

import org.apache.commons.lang.StringUtils;

import com.bum.api.core.exp.om.Metas;
import com.bum.api.core.exp.om.Params;
import com.bum.api.core.service.process.ApiProcess;
import com.bum.api.processor.dj.html.bo.DjHtmlViewBO;

public class DjHtmlProcess extends ApiProcess {
	DjHtmlViewBO	djHtmlViewBO;

	enum Func {
		home,
		song,
		songs,
		top
	}

	@Override
	public String process(String path, Params params, Metas metas) {
		String[] parts = StringUtils.split(path, "/", 3);

		Func func = null;
		if (parts.length < 2) {
			func = Func.home;
		} else {
			func = Func.valueOf(parts[1]);
		}

		switch (func) {
			case home:
				return djHtmlViewBO.home(null, params, metas);

			case songs:
				// dj/songs/moreId
				return djHtmlViewBO.songs(parts.length > 2 ? parts[2] : null, params, metas);

			case top:
				return djHtmlViewBO.top(parts.length > 2 ? parts[2] : null, params, metas);

			case song:
				/**
				 * dj/song/id
				 */
				return djHtmlViewBO.song(parts.length > 2 ? parts[2] : null, params, metas);

			default:
				break;
		}

		return djHtmlViewBO.home(path, params, metas);
	}

	public void setDjHtmlViewBO(DjHtmlViewBO djHtmlViewBO) {
		this.djHtmlViewBO = djHtmlViewBO;
	}

}
